const mongoose = require("mongoose");
const { commodity } = require("./data/commodity")

//  创建数据结构
const schema = new mongoose.Schema({
    name: String,
    desc: String,
    guarantee: String,
    aftersale: String,
    storeCondition: String,
    place: String,
    specs: String,
    pack: String,
    sales: String,
    image:[String],
})

// 创建数据模型
const commodityModel = mongoose.model("commodity", schema, "commodity");

// 创建连接
mongoose.connect(
    "mongodb://tangzhenhua:Lovo123456@182.92.214.223:8084/chenpengProject3",
    {
        useNewUrlParser: true,
        useUnifiedTopology: true,
        auth: { authSource: "admin" }
    },
    async () => {
        await commodityModel.create(commodity)
    }
)